start = (int) (input("start:"))
end = (int) (input("end:"))
mod = input("mod(e.g. 2,3,5):").split(",")
#rem = (int) (input())
rem = 0



for i in range(start,end):
    suitable = True
    for n in [3,2]:
        suitable = suitable and i % n == 0
    if i % 3 == 0 and i % 2 == 0 and True:
        print(i)




for i in range(start,end):
    suitable = True
    for m in mod:
        if i % m != rem:
            suitable = False
            break
    if suitable : 
        print(i)
            
        
        
 
 
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    